<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%
	String path = request.getContextPath() + "/";
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<head>
<base href="<%=basePath%>">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>朗读亭--公告/活动编辑</title>
<style>
tr {
	line-height: 10px;
	height: 25px;
}
</style>
<link rel="stylesheet" href="css/bootstrap.css">
</head>
<body>
	<div style="width:100%;margin-top:10px;">
		<div style="width:100%;margin-top:3px;">
			<form id="typeForm">
			<input type="hidden" name="id" id="id" value="${activity.id }" />
			<table style="width:100%;">
				<tr>
					<td class="text-right">标题：</td>
					<td><input type="text" name="title" id="title" value="${activity.title }"/></td>
				</tr>
				<tr>
					<td class="text-right">类型：</td>
					<td><select name="type">
						<option value="0" <c:if test="${activity.type=='0' }">selected</c:if>>公告</option>
						<option value="1" <c:if test="${activity.type=='1' }">selected</c:if>>活动</option>
					</select></td>
				</tr>
				<tr>
					<td class="text-right">开始时间：</td>
					<td><input type="date" name="startdate" id="startdate" value="${activity.startdate }"/></td>
				</tr>
				<tr>
					<td class="text-right">结束时间：</td>
					<td><input type="date" name="enddate" id="enddate" value="${activity.enddate }"/></td>
				</tr>
				<tr>
					<td class="text-right">内容：</td>
					<td><textarea name="content" rows="10" cols="38" style="line-height: 20px;">${activity.content }</textarea>
				</tr>
			</table>
			</form>
		</div>
		<div style="text-align: center;">
			<div style="margin-top:20px;">
				<a class="btn btn-success" onclick="saveType();" >保存</a>
			</div>
		</div>
	</div>
	<script src="js/jquery-1.9.1.js"></script>
	<script type="text/javascript" src="js/layer/layer.js"></script>
	<script type="text/javascript">
	//$(document).ready(function() {
	//    $('#startdate').datetimebox({
	//        required:true,
	//    });
	 //   $('#enddate').datetimebox({
	 //        required:true,
	 //   });
	//});
	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
		function saveType(){
			$.ajax({
				async : false,
				cache : false,
				type : 'post',
				dataType : "json",
				data : $("#typeForm").serialize(),
				url : "activity/save_activity",// 请求的action路径
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					layer.msg("请求失败！");
				},
				success : function(data) {
					if(data.state=="9003"){
						layer.msg("没有权限！");
						return ;
					}else if(data.state=="9002"){
						layer.msg("请重新登录！");
						top.location.reload();
						return ;
					}else if(data.state=="1"){
						parent.layer.close(index);
						parent.regetlist();
						layer.msg(data.message);
					}else{
						layer.msg(data.message);
					}
				}
			});	
		}
	</script>
</body>
</html>